package es.uclm.itsue.dosd;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.os.Bundle;
import android.view.View;

public class DrawBitmapActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(new myGraphicsView(this));
    }
    
    static public class myGraphicsView extends View {
    	public myGraphicsView(Context context) {
    		super(context);
    	}
    	
    	@Override
        protected void onDraw(Canvas canvas) {

    		Bitmap pic = BitmapFactory.decodeResource(
    				getResources(), R.drawable.icon);
    		canvas.drawBitmap(pic, 50, 50, null);

    		Bitmap pic2X = Bitmap.createScaledBitmap(
    				pic, pic.getWidth()*2, pic.getHeight()*2, false);

    		Matrix matrix = new Matrix();
    		matrix.preTranslate(300, 300);
    		
    		for(int i=0; i<8; i++) {
        		canvas.drawBitmap(pic2X, matrix, null);
        		matrix.preRotate(45);
    		}
        }
    }
}



